#include "common.h"

volatile struct basic_timer_reg *basic_timer6 = (volatile struct basic_timer_reg *)0x40001000;
volatile struct basic_timer_reg *basic_timer7 = (volatile struct basic_timer_reg *)0x40001400;

void init_timer6(void)
{
    basic_timer6 = (volatile struct basic_timer_reg *)0x40001000;
    rcc->APB1ENR |= (1 << 4);
    basic_timer6->CR1 |= (1);
    basic_timer6->DIER |= (1 << 0);
    basic_timer6->PSC = 359;
    basic_timer6->ARR = 200 - 1;

    nvic->ISER[1] = (1 << 22);

    basic_timer6->CR1 |= (1 << 0);
}

void TIM6_IRQHandler(void)
{
    basic_timer6->SR = 0;
    add_timer_count_variable((struct time_count *)&timer6_count, sizeof(struct timer6_count_variable) / sizeof(struct time_count));
    // adc1->CR2 |= (1<<22);
}
